boolis(int x){ if (x == 0 && ma[0]) returnfalse; while(x){ int tmp = x % 10; x /= 10; if (ma[tmp]) returnfalse; } returntrue; }
intmain(){ int n = read(); while(n--){ int x = read(); ma[x] = 1; } int ta = read(); int ans = INF; for (int i = 0; i <= 999; ++i){ int d = abs(ta - i); if (d < ans && is(i)) ans = d; } cout << ans << "\n"; return0; }